package com.itheima.mapper;

import com.itheima.pojo.Student;
import com.itheima.pojo.StudentQueryParam;
import org.apache.ibatis.annotations.*;

import java.util.List;
import java.util.Map;

@Mapper
public interface StudentMapper {


    List<Student> page(StudentQueryParam stu);

    @Insert("insert into student (name, no, gender, phone, id_card, is_college, address, degree, graduation_date, clazz_id,create_time, update_time)" +
            "values (#{name},#{no},#{gender},#{phone},#{idCard},#{isCollege},#{address},#{degree},#{graduationDate},#{clazzId},#{createTime},#{updateTime})")
    void add(Student student);


    @Select("select * from student where id = #{id}")
    Student getInfo(Integer id);


    void modify(Student s);

    void delete(List ids);

    @Update("update student set violation_score = #{score}+violation_score," +
            "violation_count=violation_count+1 where id = #{id}")
    void violate(Integer id, Integer score);


    @MapKey("name")
    List<Map> studentDegree();


    @Select("select c.name clazzList,count(*) dataList from\n" +
            "        student s,clazz c where s.clazz_id = c.id group by s.clazz_id")
    List<Map> getClszzData();
}
